fixed code after meeting with Gopi