month function and cleanup