optimize code + make private methods