changed code after feedback