some more changes including fixing first and last class function