fixed bug in algoritms (stupid Integer vs int method choice)