fixed bug in leap function