Code modified for project usage.Taking the changed code from project: cloudjee