improve code related to media