updated code with profile