succesfully merged and implemented andrew code