modified version for my own project