Updated code with application