Updated Code for proper