Updated method 1 with new functions that are used in method2