main converted into a simple method