added runtime measurement and made function returns to references