part II of magic
i took this file from other project and adapted it a bit.