code tidy up, minor performance improvement