moved code up hiearchy
fixed merge issues