shorter version of the code