changes from v1: update code style according to Andreas comments