functions added and some changed