added some cleaner code