updated main.js with lib object and conditional animation function