fixing bugs to match desired output