Reworked last commit: got rid of helper function