applying changes from comments