added posedge clk to remove latch