Modal box code refactored