rework in progress, works fine till now