implementing lhs

Please refer to http://goo.gl/oPrbpv
rearrage indentation