updated code based on kodimon
updated code based on kodimon