make main function compact