Refactor portfolio javascript code.