Working code - V1 - to be tweaked for posture