added rest of the missing code